// 导入之前封装的请求接口函数
import ajax from '@/utils/request'
import store from '@/store'

// 定义请求接口  首页获取用户选择的频道列表
const getUserChannelListAPI = () => {
  return ajax({
    method: 'GET',
    url: '/v1_0/user/channels',
    headers: {
      Authorization: `Bearer ${store.state.user.token}`
    }
  })
}

const getArticleListAPI = (channelId, timestamp = Date.now()) => {
  return ajax({
    method: 'GET',
    url: '/v1_0/articles',
    params: {
      channel_id: channelId,
      timestamp
    }
  })
}

// 导出
export {
  getUserChannelListAPI,
  getArticleListAPI
}
